*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		FIGURES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"
		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/

*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** FIGURE A16
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	

use data/processed/data_1, clear 
gen group = .
replace group = 1 if control_pure==1
replace group = 2 if control_fincrisis==1
replace group = 2 if tr_fincrisis==1
replace group = 3 if control_dotcom==1
replace group = 3 if tr_dotcom==1
replace group = 4 if control_black==1
replace group = 4 if tr_black==1

gen duration_corona = prior
replace duration_corona = recovery_duration if group==1

foreach x in 1 2 3 4 {
	sum duration_corona if group==`x', d
	*di = r(mean)
	local mean_`x' = round(r(mean), .1)
	local med_`x' = round(r(p50), .1)
	di `mean_`x''
}

histogram duration_corona if duration_corona<=20 & group==1 , ///
	 lcolor(gs8) barw(0.8) den normal ylabel(, nogrid) ytitle("") ///
	 xline(`mean_1', lpatter(dash)) note("Mean: `mean_1'; Median: `med_1'", size(small)) ///
	 xtitle("Coronavirus Crisis", size(small))  saving(Figures/temp1.gph, replace)

histogram duration_corona if duration_corona<=20 & group==2 , ///
	 lcolor(gs8) barw(0.8) den normal ylabel(, nogrid) ytitle("") xline(5.5, lcolor(red) lpatter(dash)) ///
	 xline(`mean_2', lpatter(dash)) note("Mean: 5.3; Median: `med_2'", size(small)) ///
	 xtitle("Financial Crisis 2007-09", size(small)) saving(Figures/temp2.gph, replace)

histogram duration_corona if duration_corona<=20 & group==3 , ///
	 lcolor(gs8) barw(0.8) den normal ylabel(, nogrid) ytitle("") xline(7, lcolor(red) lpatter(dash)) ///
	 xline(`mean_3', lpatter(dash)) note("Mean: `mean_3'; Median: `med_3'", size(small)) ///
	 xtitle("Dot-com bubble", size(small)) saving(Figures/temp3.gph, replace)

histogram duration_corona if duration_corona<=20 & group==4 , ///
	 lcolor(gs8) barw(0.8) den normal ylabel(, nogrid) ytitle("") xline(2, lcolor(red) lpatter(dash)) ///
	 xline(`mean_4', lpatter(dash)) note("Mean: `mean_4'; Median: `med_4'", size(small)) ///
	 xtitle("Black Monday", size(small)) saving(Figures/temp4.gph, replace)
 
	graph combine 		///
			Figures/temp1.gph ///
			Figures/temp2.gph ///
			Figures/temp3.gph ///
			Figures/temp4.gph, cols(2) ysize(3) xsize(3) iscale(.6) xcommon ycommon b1title("Years to recovery", size(small)) l1title("Density", size(small))
	
	graph export Figures/FigureA16.pdf, as(pdf) fontface("cmr10") replace		
	graph export Figures/FigureA16.png, width(1600) replace			
	

forvalues x = 1/4 {
		capture erase Figures/temp`x'.gph
}			
